﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Configuration;
using System.Web;
using System.IO;

namespace Core.DS
{
    public static partial class CourseDesign
    {
        public static dynamic addOrEditCourseDesign(int? id, string title, string description)
        {
            var sql = new Sql.SqlDataContext();
            if (id == null)
            {
                var s = new Sql.Subjects
                {
                    title = title,
                    description = description
                };
                sql.Subjects.InsertOnSubmit(s);
                sql.SubmitChanges();
                return new
                {
                    success = true
                };
            }
            var ss = sql.Subjects.FirstOrDefault(row => row.id == id);
            if (ss == null)
                return new
                {
                    msg = "找不到相应课题",
                    success = false
                };
            ss.title = title;
            ss.description = description;
            sql.SubmitChanges();
            return new
            {
                success = true
            };
        }
    }
}
